package net.dodoman;
import java.util.Calendar;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

public class HashMapTest {

	public static void main(String[] args) {
		listHashMapB();

	}

	public static void listHashMapA() {
		HashMap hashmap = new HashMap();
		for (int i = 0; i < 1000; i++) {
			hashmap.put("" + i, "hello");
		}
		long bs = Calendar.getInstance().getTimeInMillis();
		// Set set = hashmap.entrySet() ;
		Iterator it = hashmap.entrySet().iterator();
		while (it.hasNext()) {
			Map.Entry entry = (Map.Entry) it.next();
			// entry.getKey() 返回与此项对应的键
			// entry.getValue() 返回与此项对应的值
			System.out.println(entry.getValue());
		}
		System.out.println(Calendar.getInstance().getTimeInMillis() - bs);
	}

	public static void listHashMapB() {
		HashMap hashmap = new HashMap();
		for (int i = 0; i < 1000; i++) {
			hashmap.put("" + i, "hello");
		}
		long bs = Calendar.getInstance().getTimeInMillis();
		Iterator iterator = hashmap.keySet().iterator();
		// String value = "";
		while (iterator.hasNext()) {
			// value = hashmap.get(iterator.next());
			System.out.println(iterator.next());
			//System.out.println(hashmap.get(iterator.next()));
		}
		System.out.println(Calendar.getInstance().getTimeInMillis() - bs);
	}
}